/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-05-16
 * Time: 21:38
 */
//11 双指针盛水最多的容器
class Solution {
    public int maxArea(int[] height) {
        int max = 0;
        int left = 0;
        int right = height.length - 1;
        int v = 0;
        while (left < right) {
            v = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(max, v);

            //利用单调性求解
            if (height[right] > height[left]) {
                left++;
            }else {
                right--;
            }

        }

        return max;
    }
        /*public int maxArea(int[] height) {
            int max = 0;
            int left = 0;
            int right = height.length - 1;
            int v = 0;
            while (left < right) {
                //计算出两边的体积 就小的那边不用向内枚举 永远小于
                if (height[left] >= height[right]) {
                    v = (right - left) * height[right];
                    right--;
                }else {
                    v = (right - left) * height[left];
                    left++;
                }
                if (v > max) {
                    max = v;
                }
            }

            return max;
        }*/

}
